﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;

namespace Tool
{
    internal class ComProDll
    {
        /**
         * 打开设备
         */
        [DllImport("comPro.DLL", EntryPoint = "lc_init")]
        public static extern Int32 lc_init(Int32 port, Int32 baud);

        /**
         * 关闭设备
         */
        [DllImport("comPro.DLL", EntryPoint = "lc_exit")]
        public static extern Int32 lc_exit(Int32 icdev);

        /**
         * 寻卡
         */
        [DllImport("comPro.DLL", EntryPoint = "lc_card")]
        public static extern Int32 lc_card(Int32 icdev, Byte _Mode, Byte[] _Snr, Byte[] snSize, Int32[] tag, Byte[] sak); 

        /**
         * 16进制数组转字符串
         */
        [DllImport("comPro.DLL", EntryPoint = "hex_asc")]
        public static extern void hex_asc(Byte[] hex_in, Byte[] asc_out, Int32 hexLen);

        /**
         * 字符串转16进制数组
         */
        [DllImport("comPro.DLL", EntryPoint = "asc_hex")]
        public static extern void asc_hex(Byte[] asc_in, Byte[] hex_out, Int32 hexLen);

        /**
         * 验证卡
         */
        [DllImport("comPro.dll", EntryPoint = "lc_authentication")]
        public static extern Int32 lc_authentication(Int32 icdev, Byte _Mode, Byte _SecNr, Byte[] pKey);

        /**
         * 读卡
         */
        [DllImport("comPro.DLL", EntryPoint = "lc_read")]
        public static extern Int32 lc_read(Int32 icdev, Byte r_Adr, Byte[] _Data);




        /**
         * 写卡
         */
        [DllImport("comPro.DLL", EntryPoint = "lc_write")]
        public static extern Int32 lc_writer(Int32 icdev, Byte r_Adr, Byte[] _Data);




        /**
         * NFC读卡标签
         */
        [DllImport("comPro.dll", EntryPoint = "lc_NFC_ReadTag")]
        public static extern Int32 lc_NFC_ReadTag(Int32 icdev, Int32 tagType, Int32 textFormat, String strKey, Int32[] pPayloadType, Byte[] strOutData);


        /**
         * 写卡标签
         */
        [DllImport("comPro.DLL", EntryPoint = "lc_writeTag")]
        public static extern Int32 lc_writeTag(Int32 icdev, Byte r_Adr, Byte[] _Data);



        /**
         * 修改扇区密码
         */
        [DllImport("comPro.DLL", EntryPoint = "lc_updateKey")]
        public static extern Int32 lc_updateKey(Int32 hdev, Byte secNr , Byte[] pNewKeyA, Byte[] pNewCtrlW, Byte[] pNewKeyB);

    }



}
